
import * as departmentApi from '@/api/department'

const state = {
  departmentList: []
}
const mutations = {
  SET_DEPARTMENT_LIST: (state, newValue) => {
    state.departmentList = newValue
  }
}
const actions = {
  async updateDepartmentList({ commit }) {
    // 发请求
    // 拿到数据
    const res = await departmentApi.getDepartmentList()
    // 把数据传给mutation
    // mutation改数据
    commit('SET_DEPARTMENT_LIST', res)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
